<%-- 
    Document   : AddConsultant
    Created on : Feb 27, 2014, 11:03:27 AM
    Author     : Mukesh
--%>

<%@page import="FeeType.FeeTypeBean"%>
<%@page import="java.util.Iterator"%>
<%@page import="java.util.Vector"%>
<%
    try {
        if (session.getAttribute("uid") != null) {
            if (session.getAttribute("Fees_Deposit").toString().equals("1")) {
%>
<%String to = "", status = "", msg = "";%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <title>Ramgovind Automated System</title>
        <link rel="stylesheet" href="/RIT/css/bootstrap.css">
        <link rel="stylesheet" href="/RIT/css/bootstrap-responsive.css">
        <link rel="stylesheet" href="/RIT/css/jquery.fancybox.css">
        <link rel="stylesheet" href="/RIT/css/style.css">
        <link rel="stylesheet" href="/RIT/css/iconfont.css">
        <link rel="stylesheet" href="/RIT/css/bootstrap.datepicker.css">
        <script src="../../ajax/ajax.js"></script>
        <script type="text/javascript">
            /*function getEnable(id){
                document.getElementById(id).readOnly=false;
            }*/
            function checkSem(val,id)
            {
                if(isNaN(val))
                    {
                        document.getElementById(id).value="";
                    }
            }
            function getFeesDetails(val)
            {
                document.getElementById('ILoader').setAttribute("style", "visibility: visible;width: 250px;height: 250px;position: absolute;top: 50%;left:50%;margin-top: -80px;margin-left: -40px;background:url(/RIT/img/loader.gif) no-repeat;z-index: 667999;background-size:200px 200px;");
                var admid=document.getElementById('adno').value;
                var catid=document.getElementById('catid').value;
                var semester=document.getElementById('semester').value;
                var sess=document.getElementById('sess').value;
                var coid=document.getElementById('coid').value;
                if(document.getElementById('stname').value!="")
                    {
                        if(document.getElementById('semester').value!="" && !isNaN(document.getElementById('semester').value) && document.getElementById('semester').value>0)
                            {
                                var xmlhttp; 
                if (window.XMLHttpRequest)
                {
                    xmlhttp=new XMLHttpRequest();
                }
                else
                {
                    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
                }
                
                xmlhttp.onreadystatechange=function()
                {
                    if (xmlhttp.readyState==4 && xmlhttp.status==200)
                    { 
                        document.getElementById('feeDetail').innerHTML=xmlhttp.responseText; 
                        document.getElementById('ILoader').removeAttribute("style");
                    }
                }
                xmlhttp.open("POST","/RIT/FeeDetail?feeid="+val+"&admid="+admid+"&catid="+catid+"&semester="+semester+"&sess="+sess+"&coid="+coid,true);
                xmlhttp.send(); 
                            }
                            else
                                {
                                    document.getElementById('semester').value="";
                                    alert("Semester Can't be Null And Greater than 0");
                                    document.getElementById('ILoader').removeAttribute("style");
                                }
                    }
                 else
                    {
                     document.getElementById('feetype').selectedIndex=0;   
                     alert("Please Enter Admission Number");
                      document.getElementById('ILoader').removeAttribute("style");
                    }
            }
            function getStudentDetails(va)
            {
                if(!isNaN(va))
                 {
                document.getElementById('ILoader').setAttribute("style", "visibility: visible;width: 250px;height: 250px;position: absolute;top: 50%;left:50%;margin-top: -80px;margin-left: -40px;background:url(/RIT/img/loader.gif) no-repeat;z-index: 667999;background-size:200px 200px;");
                var xmlhttp; 
                if (window.XMLHttpRequest)
                {
                    xmlhttp=new XMLHttpRequest();
                }
                else
                {
                    xmvlhttp=new ActiveXObject("Microsoft.XMLHTTP");
                }
                
                xmlhttp.onreadystatechange=function()
                {
                    if (xmlhttp.readyState==4 && xmlhttp.status==200)
                    { 
                        if(xmlhttp.responseText==0)
                        {
                         document.getElementById('adno').value="";
                         document.getElementById('stname').value="";
                         document.getElementById('course').value="";
                         document.getElementById('semester').value="";
                         document.getElementById('catid').value="";
                         document.getElementById('category').value="";
                         document.getElementById('sess').value="";
                         document.getElementById('coid').value="";
                         alert("No Record Found");
                        }
                        else
                        {
                            var val=xmlhttp.responseText.split("--");
                            document.getElementById('stname').value=val[0];
                            document.getElementById('course').value=val[1];
                            document.getElementById('semester').value=val[2];
                            document.getElementById('catid').value=val[3];
                            document.getElementById('category').value=val[4];
                            document.getElementById('sess').value=val[5];
                            document.getElementById('coid').value=val[6];
                            document.getElementById('ILoader').removeAttribute("style");
                        }
                    }
                }
                xmlhttp.open("POST","/RIT/StudentDetail?admiId="+va,true);
                xmlhttp.send();
                 }
                 else
                     {
                         document.getElementById('adno').value="";
                         alert("Please Enter Admission Number in Digits");   
                     }
            }
            function checkValue(id,val)
            {
                if(isNaN(val))
                    {
                        document.getElementById(id).value="0";  
                    }
            }
            function calculateFees(id)
            {
                var hidd=document.getElementById('hfeeid').value.split("/");
                var spid=id.split("-");
                if(document.getElementById(id).checked)
                    {
                        var total=(parseInt(document.getElementById(spid[0]+"-a").value)+parseInt(document.getElementById(spid[0]+"-add").value))-parseInt(document.getElementById(spid[0]+"-r").value);
                        document.getElementById(spid[0]+"-p").value=total;
                        var t=0;
                        for(var i=0;i<hidd.length-1;i++)
                        {
                            t=parseInt(t)+parseInt(document.getElementById(hidd[i]+"-p").value);
                            document.getElementById('total').value=t;    
                        }
                    }
                else
                    {
                        document.getElementById(spid[0]+"-add").value="0";
                        document.getElementById(spid[0]+"-r").value="0";
                        document.getElementById(spid[0]+"-p").value="0";
                        var t1=0;
                        for(var i=0;i<hidd.length-1;i++)
                        {
                            t1=parseInt(t1)+parseInt(document.getElementById(hidd[i]+"-p").value);
                            document.getElementById('total').value=t1;    
                        }   
                    }
                    document.getElementById('bamnt').value=parseFloat(document.getElementById('total').value)-parseFloat(document.getElementById('paid').value);
            }
            function calculate(id)
            {
                 var spid=id.split("-");
                 var hidd=document.getElementById('hfeeid').value.split("/");
                if(document.getElementById(spid[0]+"-c").checked)
                {
                    if(spid[1]=="r")
                     {
                    document.getElementById(spid[0]+"-p").value=parseInt(document.getElementById(spid[0]+"-p").value)+parseInt(document.getElementById(id).value);
                     }
                     else
                         {
                             document.getElementById(spid[0]+"-p").value=parseInt(document.getElementById(spid[0]+"-p").value)-parseInt(document.getElementById(id).value);
                         }
                    var t1=0;
                        for(var i=0;i<hidd.length-1;i++)
                        {
                            t1=parseInt(t1)+parseInt(document.getElementById(hidd[i]+"-p").value);
                            document.getElementById('total').value=t1;    
                        }
                }
                else
                    {
                        document.getElementById(id).value="0";
                    }
            }
            function recalculate(id)
            {
                 var spid=id.split("-");
                 var hidd=document.getElementById('hfeeid').value.split("/");
                if(document.getElementById(spid[0]+"-c").checked)
                {
                    document.getElementById(spid[0]+"-p").value=(parseInt(document.getElementById(spid[0]+"-a").value)+parseInt(document.getElementById(spid[0]+"-add").value))-parseInt(document.getElementById(spid[0]+"-r").value);
                    var t1=0;
                        for(var i=0;i<hidd.length-1;i++)
                        {
                            t1=parseInt(t1)+parseInt(document.getElementById(hidd[i]+"-p").value);
                            document.getElementById('total').value=t1;    
                        }
                }
                else
                    {
                        document.getElementById(id).value="0";
                    }
               document.getElementById('bamnt').value=parseFloat(document.getElementById('total').value)-parseFloat(document.getElementById('paid').value);
            }
            function enableButton(val)
            {
                if(val=="")
                    {
                       document.getElementById('subfm').disabled=true;
                       document.getElementById('bank').removeAttribute("class");
                       document.getElementById('branch').removeAttribute("class");
                       document.getElementById('cheque').removeAttribute("class");
                    }
                 else if(val=="0")
                        {
                            document.getElementById('bank').removeAttribute("class");
                            document.getElementById('branch').removeAttribute("class");
                            document.getElementById('cheque').removeAttribute("class");
                            document.getElementById('subfm').disabled=false;
                        }
                 else if(val=="1")
                     {
                         document.getElementById('bank').className="required";
                         document.getElementById('branch').className="required";
                         document.getElementById('cheque').className="required";
                         document.getElementById('subfm').disabled=false;
                     }
                 else
                     {
                         document.getElementById('bank').setAttribute("class","required");
                         document.getElementById('branch').setAttribute("class","required");
                         document.getElementById('cheque').setAttribute("class","required");
                         document.getElementById('subfm').disabled=false; 
                     }
            }
        </script>
    </head>
    <body>
        <div id="ILoader"></div>
        <%@include file="/topheader.html" %>
        <%@include file="/servicesheader.html" %>
        <div class="main">
            <div class="container-fluid">
                <%@include file="/Services/Accounts/accsidenav.jsp" %>
                <div class="content">
                    <%if (session.getAttribute("status") != null) {
                            status = session.getAttribute("status").toString();
                            msg = session.getAttribute("msg").toString();
                    %>
                    <div class="alert alert-success alert-block">
                        <a class="close" data-dismiss="alert" href="#"><img src="/RIT/img/mclose.png"></a>
                        <h4 class="alert-heading"> <%=status%></h4>
                        <%=msg%>

                    </div>
                    <%session.removeAttribute("status");
                            session.removeAttribute("msg");
                        }%>
                    <div class="row-fluid">
                        <div class="span12">
                            <div class="box">
                                <div class="box-head">
                                    <h3>Deposit Fees</h3>
                                    <a href="Accounts.jsp">
                                        <button style="float: right" class="btn btn-success">View Fees Deposit</button>
                                    </a>
                                </div>
                                <form action="/RIT/AddStudentFees" method="post" class='validate form-horizontal'>
                                    <div class="box-content">
                                        <!---Form Start....-->

                                        <div id="lside" style="float: left; margin-top: 10px;">
                                            <div class="control-group">
                                                <label for="adno" class="control-label">Admission No.<span style="color:red">*</span></label>
                                                <div class="controls">
                                                    <input type="text" name="adno" id="adno" class='required' onblur="getStudentDetails(this.value)">
                                                </div>
                                            </div>
                                            <div class="control-group">
                                                <label for="course" class="control-label">Course/Stream<span style="color:red"></span></label>
                                                <div class="controls">
                                                    <input type="text" name="course" id="course" class='required' readonly>
                                                </div>
                                            </div>
                                            <div class="control-group">
                                                <label for="add" class="control-label">Category<span style="color:red"></span></label>
                                                <div class="controls">
                                                    <input type="text" name="category" id="category" class="required" readonly>
                                                    <input type="hidden" name="catid" id="catid" class="required">
                                                    <input type="hidden" name="sess" id="sess" class="required">
                                                    <input type="hidden" name="coid" id="coid" class="required">
                                                </div>
                                            </div>
                                        </div>
                                        <div id="rside" style="float: left; margin-top: 10px">
                                            <div class="control-group">
                                                <label for="name" class="control-label">Name<span style="color:red"></span></label>
                                                <div class="controls">
                                                    <input type="text" name="stname" id="stname" class="required" readonly>
                                                </div>
                                            </div>
                                            <div class="control-group">
                                                <label for="semester" class="control-label">Semester<span style="color:red">*</span></label>
                                                <div class="controls">
                                                    <input type="text" name="semester" id="semester" class="required" readonly onblur="checkSem(this.value,this.id)">
                                                    <!--<a href="#"><img alt="edit" title="Edit" class="ico-prev" id="editsem" name="editsem"  onclick="getEnable('semester')" src="/RIT/img/icons/essen/16/pencil.png"></a>-->
                                                </div>
                                            </div>
                                            <div class="control-group">
                                                <label for="feetype" class="control-label">Fee Type<span style="color:red">*</span></label>
                                                <div class="controls">
                                                    <select name="feetype" id="feetype" class='{required:true}' onchange="getFeesDetails(this.value)">
                                                                <option value="">Select Fee Type</option>
                                                <%
                                                    Vector<Object> list=FeeType.Query.viewAll();
                                                    Iterator it=list.iterator();
                                                    while(it.hasNext())
                                                    {
                                                    FeeTypeBean fb=(FeeTypeBean)it.next();
                                                %>
                                                <option value="<%=fb.getFeeTypeId()%>"><%=fb.getFeeTypeName()%></option>
                                                <%
                                                    }
                                                %>
                                                   </select>
                                                </div>
                                            </div>
                                        </div>
                                                   <div id="feeDetail">
                                                   </div>
                                        <!---Form Ends....-->
                                    </div>
                                    <div class="form-actions">
                                        <input type="submit" class='btn btn-primary' disabled id="subfm">
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>	
            </div>
        </div>
        <script src="/RIT/js/jquery.js"></script>
        <script src="/RIT/js/less.js"></script>
        <script src="/RIT/js/bootstrap.min.js"></script>
        <script src="/RIT/js/jquery.uniform.min.js"></script>
        <script src="/RIT/js/bootstrap.timepicker.js"></script>
        <script src="/RIT/js/bootstrap.datepicker.js"></script>
        <script src="/RIT/js/chosen.jquery.min.js"></script>
        <script src="/RIT/js/jquery.fancybox.js"></script>
        <script src="/RIT/js/plupload/plupload.full.js"></script>
        <script src="/RIT/js/plupload/jquery.plupload.queue/jquery.plupload.queue.js"></script>
        <script src="/RIT/js/jquery.cleditor.min.js"></script>
        <script src="/RIT/js/jquery.inputmask.min.js"></script>
        <script src="/RIT/js/jquery.tagsinput.min.js"></script>
        <script src="/RIT/js/jquery.mousewheel.js"></script>
        <script src="/RIT/js/jquery.textareaCounter.plugin.js"></script>
        <script src="/RIT/js/ui.spinner.js"></script>
        <script src="/RIT/js/jquery.jgrowl_minimized.js"></script>
        <script src="/RIT/js/jquery.form.js"></script>
        <script src="/RIT/js/jquery.validate.min.js"></script>
        <script src="/RIT/js/bbq.js"></script>
        <script src="/RIT/js/jquery-ui-1.8.22.custom.min.js"></script>
        <script src="/RIT/js/jquery.form.wizard-min.js"></script>
        <script src="/RIT/js/jquery.cookie.js"></script>
        <script src="/RIT/js/jquery.metadata.js"></script>
        <script src="/RIT/js/custom.js"></script><script src="/RIT/js/demo.js"></script>
        <script src="/RIT/js/iconfont.js"></script>
    </body>
</html>

<%} else {
%>
<script type="text/javascript">
    alert("You Are Not Authorised");
    window.history.back();
</script>
<%             }
        } else {
            request.setAttribute("msg", "You Are Not Authorised! Please Contact to System Administrator!");
            request.setAttribute("value", "0");
            getServletContext().getRequestDispatcher("/index.jsp").forward(request, response);
        }
    } catch (Exception e) {
        request.setAttribute("msg", "Please Contact to System Administrator!");
        request.setAttribute("value", "0");
        getServletContext().getRequestDispatcher("/index.jsp").forward(request, response);
    }
%>

